package demo2;

public class Test2 {
    public boolean isNumOrCharacter(char s) {
        if (s >= 'a' && s <= 'z') {
            return false;
        }
        return true;
    }
    public boolean isPalindrome(String s) {
        //先全部转为小写
        String ret = s.toLowerCase();
        //之后直接双指针
        int i = 0;
        int j = ret.length() - 1;
        while (i <= j) {
            while (isNumOrCharacter(ret.charAt(i))) {
                i++;
            }
            while(isNumOrCharacter(ret.charAt(j))) {
                j--;
            }
            if (ret.charAt(i) == ret.charAt(j)) {
                i++;
                j--;
            }else {
                return false;
            }
        }
        return true;

    }
    public static void main3(String[] args) {
        String a = "abc";
        System.out.println(a.length());
    }
    public int firstUniqChar(String s) {
        //利用哈希
        //之后遍历字符串找出即可
        int[] count = new int[26];
        for (int i = 0; i < s.length(); i++) {
            count[s.charAt(i) - 'a']++;
        }
        for (int i = 0; i < s.length(); i++) {
            if (count[s.charAt(i) - 'a'] == 1) {
                return i;
            }
        }
        return -1;
    }
    public static void main2(String[] args) {
        String str = "hello";
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(str);
        stringBuilder.append("abc");
        str = stringBuilder.toString();
        System.out.println(str);
    }
    public static void main1(String[] args) {
        String str = "hello";
        str = str + "abc";
        System.out.println(str);
    }
}
